package com.cy.stone.framework.mybatisflex;

import com.cy.stone.common.base.BaseEntity;
import com.mybatisflex.core.FlexGlobalConfig;
import com.mybatisflex.core.dialect.DbType;
import com.mybatisflex.spring.boot.MyBatisFlexCustomizer;
import org.springframework.context.annotation.Configuration;

/**
 * Mybatis-Flex配置
 * @author Wings
 * @since 2023-12-16
 */
@Configuration
public class MybatisFlexConfig implements MyBatisFlexCustomizer {

    @Override
    public void customize(FlexGlobalConfig flexGlobalConfig) {
        flexGlobalConfig.setDbType(DbType.MYSQL);
        DefaultInsertListener insertListener = new DefaultInsertListener();
        DefaultUpdateListener updateListener = new DefaultUpdateListener();
        flexGlobalConfig.registerInsertListener(insertListener, BaseEntity.class);
        flexGlobalConfig.registerUpdateListener(updateListener, BaseEntity.class);
    }
}
